import { Injectable } from '@angular/core';
import {Observable} from "rxjs/Observable";
import {DamAPI} from "../../peach-constants";
import {MsgResult} from "../../../../models/msg-result";
import {RequestUtil} from "../../../../util/request-util";

@Injectable()
export class SlagService {

  constructor(
    private requestUtil: RequestUtil
  ) { }
  getCarType():Observable<MsgResult>{
    return this.requestUtil.get(DamAPI.carType);
  }
  getCarStatus():Observable<MsgResult>{
    return this.requestUtil.get(DamAPI.carStatus);
  }
  getCarTypeNum():Observable<MsgResult>{
    return this.requestUtil.get(DamAPI.carTypeNum);
  }
  getCarRealPoint(deviceType,deviceStatus,regionCode):Observable<MsgResult>{
    let params = "deviceType="+deviceType+"&deviceStatus="+deviceStatus+"&regionCode="+regionCode;
    return this.requestUtil.get(DamAPI.carRealPoint,params);
  }
  getCarRealAreaPoint(obj):Observable<MsgResult>{
    let params = "deviceType="+obj.deviceType+"&deviceStatus="+obj.deviceStatus+"&regionCode="+obj.regionCode+"&longitude="+obj.longitude+"&latitude="+obj.latitude+"&radius="+obj.radius;
    return this.requestUtil.get(DamAPI.carRealAreaPoint,params);
  }
  getCarHistoryPoint(obj):Observable<MsgResult>{
    let params = "lngSets="+obj.lngSets+"&latSets="+obj.latSets+"&deviceType="+obj.deviceType+"&deviceStatus="+obj.deviceStatus+"&startTime="+obj.startTime+"&endTime="+obj.endTime+"&regionCode="+obj.regionCode;
    return this.requestUtil.get(DamAPI.carHistoryPoint,params);
  }

  getCarSearchData(carCode):Observable<MsgResult>{
    let params = "carCodeLike="+carCode;
    return this.requestUtil.get(DamAPI.carSearchByCode,params);
  }

  getRegionsTreeByRegion(): Observable<MsgResult> {
    return this.requestUtil.get(DamAPI.getRetrieveRegionsTree);
  }

  getHistoryGPSData(obj): Observable<MsgResult> {
    let params = 'startTime='+obj.startTime+'&endTime='+obj.endTime+'&deviceCode='+obj.deviceCode;
    return this.requestUtil.get(DamAPI.historyGPSData,params);
  }
}
